import { NextRequest, NextResponse } from 'next/server'
import { getTools } from '@/lib/database'
import { requireAdmin, withErrorHandling } from '@/lib/auth-middleware'

export const GET = withErrorHandling(async (request: NextRequest) => {
  return requireAdmin(request, async (req) => {
    console.log('管理员获取工具列表:', req.user?.name)

    const tools = await getTools(request)

    return NextResponse.json({
      success: true,
      data: tools,
      message: `获取到 ${tools.length} 个工具`
    })
  })
})
